home *** CD-ROM | disk | FTP | other *** search
/ Libris Britannia 4 / science library(b).zip / science library(b) / DJGPP / CBGRX103.ZIP / contrib / libgrx / src / p4pixblk.c < prev    next >
Text File  |  1993-12-06  |  3KB  |  114 lines

  1. /** 
  2.  ** P4PIXBLK.C 
  3.  **
  4.  **  Copyright (C) 1992, Csaba Biegl
  5.  **    820 Stirrup Dr, Nashville, TN, 37221
  6.  **    csaba@vuse.vanderbilt.edu
  7.  **
  8.  **  This file is distributed under the terms listed in the document
  9.  **  "copying.cb", available from the author at the address above.
  10.  **  A copy of "copying.cb" should accompany this file; if not, a copy
  11.  **  should be available from where this file was obtained.  This file
  12.  **  may not be distributed without a verbatim copy of "copying.cb".
  13.  **  You should also have received a copy of the GNU General Public
  14.  **  License along with this program (it is in the file "copying");
  15.  **  if not, write to the Free Software Foundation, Inc., 675 Mass Ave,
  16.  **  Cambridge, MA 02139, USA.
  17.  **
  18.  **  This program is distributed in the hope that it will be useful,
  19.  **  but WITHOUT ANY WARRANTY; without even the implied warranty of
  20.  **  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  21.  **  GNU General Public License for more details.
  22.  **/
  23.  
  24. #include "p4.h"
  25. #include "memfill.h"
  26. #include "memcopy.h"
  27.  
  28. void _GrP4SetPixBlock(long addr,int color,int width,int height)
  29. {
  30.     pixptr p = P_ADDRESS(CURC,addr);
  31.     int opr  = C_OPER(color);
  32.     int offs = CURC->gc_lineoffset;
  33.     int plane,lmask,rmask;
  34.  
  35.     if((width <= 0) || (height <= 0)) return;
  36.     if((_GrP4DrawTable[opr] ^ (color &= C_SIGNIF)) == 0) return;
  37.     _ClrDir();
  38.     _ComputeMasks(addr,width,lmask,rmask);
  39.     if(CURC->gc_onscreen) {
  40.         _SetVideoColor(color,opr);
  41.         if(lmask) {
  42.         _SetVGAWriteMask(lmask);
  43.         _ColSetXorB(VLEFT,p,offs,0,height);
  44.         p++;
  45.         }
  46.         if(width) {
  47.         _SetVGAWriteMask(0xff);
  48.         plane = offs - width;
  49.         if(opr == C_SET)
  50.             _BlkSetB(VBODY,p,plane,0,width,height);
  51.         else {
  52.             _SaveDS();
  53.             _BlkCpyB(VBODY,p,plane,p,plane,width,height);
  54.             _RestoreDS();
  55.         }
  56.         p += width;
  57.         }
  58.         if(rmask) {
  59.         _SetVGAWriteMask(rmask);
  60.         _ColSetXorB(VRIGHT,p,offs,0,height);
  61.         }
  62.         return;
  63.     }
  64.     opr <<= 1;
  65.     for(plane = 4; --plane >= 0; color >>= 1) {
  66.         pixptr pp = p;
  67.         switch(opr | (color & 1)) {
  68.           case C_XOR2+1:
  69.         if(lmask) {
  70.             _ColSetXorB(MLEFT_X,pp,offs,lmask,height);
  71.             pp++;
  72.         }
  73.         if(width) {
  74.             _BlkSetXorB(MBODY_X,pp,(offs - width),0xff,width,height);
  75.             pp += width;
  76.         }
  77.         if(rmask) {
  78.             _ColSetXorB(MRIGHT_X,pp,offs,rmask,height);
  79.         }
  80.         break;
  81.           case C_OR2+1:
  82.           case C_SET2+1:
  83.         if(lmask) {
  84.             _ColSetOrB(MLEFT_1,pp,offs,lmask,height);
  85.             pp++;
  86.         }
  87.         if(width) {
  88.             _BlkSetB(MBODY_1,pp,(offs - width),0xff,width,height);
  89.             pp += width;
  90.         }
  91.         if(rmask) {
  92.             _ColSetOrB(MRIGHT_1,pp,offs,rmask,height);
  93.         }
  94.         break;
  95.           case C_AND2+0:
  96.           case C_SET2+0:
  97.         if(lmask) {
  98.             _ColSetAndB(MLEFT_0,pp,offs,~lmask,height);
  99.             pp++;
  100.         }
  101.         if(width) {
  102.             _BlkSetB(MBODY_0,pp,(offs - width),0,width,height);
  103.             pp += width;
  104.         }
  105.         if(rmask) {
  106.             _ColSetAndB(MRIGHT_0,pp,offs,~rmask,height);
  107.         }
  108.         break;
  109.         }
  110.         p = (pixptr)((long)p + CURC->gc_planeoffset);
  111.     }
  112. }
  113.  
  114.